﻿<Controls:MetroWindow xmlns:my1="clr-namespace:ExORMDesginer.UserControls"  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
        xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
        xmlns:Custom="http://metro.mahapps.com/winfx/xaml/shared" 
        xmlns:my="clr-namespace:EasyEntities.RIA.Controls;assembly=EasyEntities.RIA.Controls"
		xmlns:UC="clr-namespace:ExORMDesginer.UserControls"
        xmlns:s="clr-namespace:DiagramDesigner"
        xmlns:plugin="clr-namespace:ExORMDesginer.Plugin;assembly=ExORMDesginer.Plugin"
        xmlns:Model="clr-namespace:ExORMDesginer.Models"
        xmlns:Helpler="clr-namespace:ExORMDesginer.Helper"
        xmlns:Converters1="clr-namespace:ExtendPropertyLib.XAML.Converters;assembly=ExtendPropertyLib.WPF"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
		x:Class="ExORMDesginer.MainView"
        Height="768" Width="1024"
        WindowState="Maximized"     
        ShowTitleBar="True"
        TextOptions.TextRenderingMode="ClearType"
        ShowIconOnTitleBar="true" 
        Icon="/ExORMDesginer;component/Images/window.png">


    <Controls:MetroWindow.WindowCommands>
        <Controls:WindowCommands>
            <Button Content="设置" />
            <Button Content="帮助" />
        </Controls:WindowCommands>
    </Controls:MetroWindow.WindowCommands>
    <Controls:MetroWindow.Resources>
        <Converters1:BoolToVisibilityConverter x:Key="bool2Visable"/>
     
    </Controls:MetroWindow.Resources>
   
    <Controls:MetroContentControl>
        <Grid Background="#FF1D1C1C">
           
            <TabControl>
                <TabItem Header="元数据">
                    <Grid x:Name="LeftBar">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.5" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid Grid.Column="0"  >
                            <Border Margin="2,0,0,0"  BorderThickness="1,1,0.5,1" >
                                <Border.BorderBrush>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF555454" Offset="0"/>
                                        <GradientStop Color="#FF8D8D8D" Offset="1"/>
                                        <GradientStop Color="#FF625E5E" Offset="0.501"/>
                                    </LinearGradientBrush>
                                </Border.BorderBrush>
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="1.993,0.356" StartPoint="-0.353,0.359">
                                        <GradientStop Color="#FF1D1D1D" Offset="0"/>
                                        <GradientStop Color="#FE191818" Offset="0.409"/>
                                        <GradientStop Color="#FE0F0F0F" Offset="0.649"/>
                                        <GradientStop Color="#FE0F0F0F" Offset="1"/>
                                    </LinearGradientBrush>
                                </Border.Background>
                              
                                <DockPanel>
                                    <Border DockPanel.Dock="Top" BorderThickness="0.3" CornerRadius="1" Height="22">
                                        <Border.Background>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#FF4B4B4B" Offset="0" />
                                                <GradientStop Color="Black" Offset="1" />
                                            </LinearGradientBrush>
                                        </Border.Background>
                                        <TextBlock Text="数据源列表" HorizontalAlignment="Center" VerticalAlignment="Center" Width="70" FontSize="13" Foreground="WhiteSmoke" FontWeight="Bold" />
                                    </Border>
                                    <Grid Margin="0,5,0,0">

                                        <telerik:RadTreeView ItemsSource="{Binding Model.Folders}" IsDragDropEnabled="True" IsDragPreviewEnabled="False" telerik:AnimationManager.IsAnimationEnabled="False" SelectionMode="Multiple"
                                Name="radTreeView1" BorderThickness="0" FontSize="13" FontWeight="Bold"  Background="{x:Null}">

                                            <telerik:RadContextMenu.ContextMenu>
                                                <telerik:RadContextMenu x:Name="radContextMenu" Opened="RadContextMenu_Opened" />
                                            </telerik:RadContextMenu.ContextMenu>

                                            <telerik:RadTreeView.ItemContainerStyle>
                                                <Style TargetType="{x:Type telerik:RadTreeViewItem}">
                                                    <Setter Property="IsExpanded" Value="True" />
                                                </Style>
                                            </telerik:RadTreeView.ItemContainerStyle>
                                            <telerik:RadTreeView.Resources>
                                                <HierarchicalDataTemplate DataType="{x:Type Model:FolderInfo}"  ItemsSource="{Binding Items,UpdateSourceTrigger=PropertyChanged}">
                                                    <StackPanel  Orientation="Horizontal">
                                                        <Image  Width="18" Height="18" Source="/ExORMDesginer;component/Images/table.png" />
                                                        <TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="5,0,0,0"  />
                                                    </StackPanel>
                                                </HierarchicalDataTemplate>
                                                <DataTemplate DataType="{x:Type plugin:DbEntity}">
                                                    <StackPanel  Orientation="Horizontal">
                                                        <Image  Width="16" Height="16" Source="/ExORMDesginer;component/Images/model.png" />
                                                        <TextBlock Text="{Binding DisplayName}" VerticalAlignment="Center" Margin="5,0,0,0"  />
                                                    </StackPanel>
                                                </DataTemplate>
                                            </telerik:RadTreeView.Resources>

                                        </telerik:RadTreeView>
                                    </Grid>
                                </DockPanel>

                            </Border>
                         
                        </Grid>
                        <GridSplitter Background="Transparent"  BorderThickness="0"  Width="2" Grid.Column="0"/>
                        <Grid Grid.Column="1" Margin="2,0,0,0" >
                        	<Grid.ColumnDefinitions>
                        		<ColumnDefinition Width="45"/>
                        		<ColumnDefinition Width="0.927*"/>
                        	</Grid.ColumnDefinitions>
                         	
							
							
							<Border Grid.Column="0" CornerRadius="3" BorderBrush="#FF8D8D8D" BorderThickness="0.7,0.7,0.7,0.7">
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                        <GradientStop Color="#FF383838" Offset="0" />
                                        <GradientStop Color="#FF242020" Offset="1" />
                                    </LinearGradientBrush>
                                </Border.Background>
                                <StackPanel>
                                    <Grid Height="45" Width="45" Margin="0,8,0,0">
                                    <Controls:AppBarButton x:Name="rotate" VerticalAlignment="Center" HorizontalAlignment="Center"  Height="33" Width="33" MetroImageSource="{DynamicResource Previous}" Click="AppBarButton_Click"   ToolTip="说明:将元数据列表 dock left for hide。">
                                        <Controls:AppBarButton.LayoutTransform>
                                            <RotateTransform CenterX="0.5" CenterY="0.5" Angle="180" />
                                        </Controls:AppBarButton.LayoutTransform>
                                    </Controls:AppBarButton>
                                    </Grid>
                                    <Controls:AppBarButton Name="New" Margin="0,2,0,0" Height="45" Width="40" MetroImageSource="{DynamicResource New}" ToolTip="说明:建立新的项目，包括表元数据、数据设计、业务设计、界面生成、代码生成等。"  >
										<TextBlock Text="新建" FontSize="9"/>
									</Controls:AppBarButton>
                                    <Controls:AppBarButton Name="Open" Margin="0,8,0,0" Height="45" Width="40" MetroImageSource="{DynamicResource Folder}"   ToolTip="说明:建立新的项目，包括表元数据、数据设计、业务设计、界面生成、代码生成等。" >
                                        <TextBlock Text="打开" FontSize="9"/>
                                    </Controls:AppBarButton>
                                    <Controls:AppBarButton Name="Save" Margin="0,8,0,0" Height="45" Width="40" MetroImageSource="{DynamicResource Floppy}"   ToolTip="说明:保存项目模型信息到文件系统中。" >
										<TextBlock Text="保存" FontSize="9"/>
									</Controls:AppBarButton>
                                    <Controls:AppBarButton Margin="0,8,0,0" Height="45" Width="40" MetroImageSource="{DynamicResource Properties}"  ToolTip="说明:系统设置选项。">
                                        <TextBlock Text="设置" FontSize="9" />
                                    </Controls:AppBarButton>
   
                                    <Border BorderThickness="0.7" BorderBrush="DarkGray" Width="30" Height="1" Margin="0,8,0,0" HorizontalAlignment="Center"/>
                                    <Controls:AppBarButton Name="ConnectionDatabase" Margin="0,8,0,0" Height="45" Width="40" MetroImageSource="{DynamicResource Data Add}" ToolTip="说明:连接数据库，并测试连接状态和管理连接组。" >
                                        <TextBlock Text="数据库" FontSize="9"/>
                                    </Controls:AppBarButton>
                                    <Controls:AppBarButton x:Name="SyncDataBase"  Margin="0,8,0,0" Height="45" Width="40" MetroImageSource="{DynamicResource Exchange}" ToolTip="说明:在有可用的数据连接后，将物理表构架信息同步到元数据信息中。"  >
										<TextBlock Text="同步" FontSize="9"/>
									</Controls:AppBarButton>
                                    <Border BorderThickness="0.7" BorderBrush="DarkGray" Width="30" Height="1" Margin="0,8,0,0" HorizontalAlignment="Center"/>
                                    <Controls:AppBarButton x:Name="ConnectionIDE"  Margin="0,8,0,0" Height="45" Width="40" MetroImageSource="{DynamicResource Window New}" ToolTip="说明:在有可用的数据连接后，将物理表构架信息同步到元数据信息中。"  >
                                        <TextBlock Text="连接VS" FontSize="9"/>
                                    </Controls:AppBarButton>
                                    <Controls:AppBarButton x:Name="GenerationDocument"  Margin="0,8,0,0" Height="45" Width="40" MetroImageSource="{DynamicResource Data Down}" ToolTip="说明:在有可用的数据连接后，将物理表构架信息同步到元数据信息中。"  >
                                        <TextBlock Text="生成文档" FontSize="9"/>
                                    </Controls:AppBarButton>
                                    
                             
                                </StackPanel></Border>
                          		<Grid Grid.Column="1" >
                              
                                <UC:CanvasDesginer x:Name="Desginer" ItemsSource="{Binding Model.DisplayEntitys,IsAsync=True}"/>
                                <Border Height="30"  CornerRadius="3" VerticalAlignment="Top"  Panel.ZIndex="99" Margin="10,0,20,0" Background="#FF272626" Opacity="0.95" BorderThickness="0.5,0,0.5,0.5" BorderBrush="#FF3F3F46">
                                    <Border.Effect>
                                        <DropShadowEffect BlurRadius="3" Opacity="0.88" ShadowDepth="1" Direction="335"/>
                                    </Border.Effect>
                                    <Grid  >
                                    <StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Left" Width="350" Margin="15,0,0,0">
                                        <Border VerticalAlignment="Center" Width="10" Height="10" CornerRadius="3" Background="#FFF5EEEE"></Border>
                                        <TextBlock VerticalAlignment="Center" Text="表" Foreground="WhiteSmoke" Margin="5,0,0,0" FontWeight="Bold" FontSize="14"/>
                                        <Border VerticalAlignment="Center" Width="10" Height="10" CornerRadius="3" Background="#FFCB0961" Margin="7,0,0,0"></Border>
                                        <TextBlock VerticalAlignment="Center" Text="视图" Foreground="WhiteSmoke" Margin="5,0,0,0" FontWeight="Bold" FontSize="14"/>
                                        <Border VerticalAlignment="Center" Width="10" Height="10" CornerRadius="3" Background="#FFFFF699" Margin="7,0,0,0"></Border>
                                        <TextBlock VerticalAlignment="Center" Text="存储过程" Foreground="WhiteSmoke" Margin="5,0,0,0" FontSize="14" FontWeight="Bold"/>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center"   Margin="0,2,28,0">
                                        <Controls:AppBarButton  Height="20" Width="20" MetroImageSource="{DynamicResource Rename}" Command="{x:Static s:DesignerCanvas.SelectMode}"  CommandTarget="{Binding ElementName=Desginer,Path=DesignerCanvas}"  ToolTip="说明:用于元数据设计视图中选择模型的拾取器。" >
                                        </Controls:AppBarButton>
                                        <TextBlock Text="鼠标" Foreground="WhiteSmoke" VerticalAlignment="Center" Margin="3,0,0,0" FontWeight="Bold" FontSize="14" />
                                        <Controls:AppBarButton  Height="20" Width="20" MetroImageSource="{DynamicResource Search}" Command="{x:Static s:DesignerCanvas.HandMode}"  CommandTarget="{Binding ElementName=Desginer,Path=DesignerCanvas}"  ToolTip="说明:用于元数据设计视图中拖/移动视图画布。" Margin="3,0,0,0">
                                        </Controls:AppBarButton >
                                        <TextBlock Text="拾取" Foreground="WhiteSmoke" VerticalAlignment="Center" Margin="3,0,0,0" FontWeight="Bold" FontSize="14" />
                                    </StackPanel>
                                 
                                </Grid>
                                </Border>
                                <telerik:RadExpander Opacity="0.8"  Panel.ZIndex="999" IsExpanded="False" ExpandDirection="Down"   HorizontalAlignment="Right" VerticalAlignment="Top"   Margin="0,2,152,0">
                                    <telerik:RadExpander.Header>
                                        <TextBlock VerticalAlignment="Center" Foreground="WhiteSmoke" Text="查询" FontSize="14" FontWeight="Bold"/>
                                    </telerik:RadExpander.Header>
                                    <Border   Height="35" Width="190"  BorderThickness="1" CornerRadius="3" BorderBrush="#FF5C5B5B"  Background="#FF313131">
                                        <StackPanel Orientation="Horizontal" >

                                            <TextBlock Text="表名:" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Center" FontWeight="Bold" Margin="6,0,0,0" FontSize="10.667"/>
                                            <TextBox Text="{Binding FindName}" Width="100" Height="22" Margin="6,0,0,0" />
                                            <Button Name="FindTableByName" Content="查找" VerticalAlignment="Center" Height="22" Width="42" Margin="5,0,0,0" />
                                        </StackPanel>
                                    </Border>
                                </telerik:RadExpander>
                                <telerik:RadExpander   IsExpanded="False" ExpandDirection="Up"   HorizontalAlignment="Left" VerticalAlignment="Bottom"   Margin="0,5,0,7">
                                    <telerik:RadExpander.Header>
                                        <Border CornerRadius="1.5" Background="#FF0F0F0F" MinWidth="75" Opacity="0.8">
                                            <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                                                <TextBlock  Text="输出日志"   Foreground="WhiteSmoke" />
                                                <Rectangle Fill="#FF8F2FA4" Height="3" Width="50" />
                                            </StackPanel >
                                           

                                        </Border>
                                    </telerik:RadExpander.Header>

                                    <Border   Height="160" MinWidth="730"  BorderThickness="1" CornerRadius="1.7" BorderBrush="#FF8F2FA4"  Background="#FF171717" Opacity="0.9">
                                        <TextBox Text="{Binding Model.Log.Message}" VerticalScrollBarVisibility="Visible" TextWrapping="Wrap"  AcceptsReturn="True"   Foreground="#FFDA1793" Background="#FF0F0F0F" BorderBrush="#FF8F2FA4" TextChanged="TextBox_TextChanged_1" FontFamily="Microsoft YaHei" FontSize="12" />
                                    </Border>
                                </telerik:RadExpander>
                            </Grid>
                        </Grid>
                    </Grid>
                </TabItem>
                <TabItem Header="数据设计">
                    <ContentControl Content="{Binding DatabaseExplorerViewModel.View}"/>
                  
                </TabItem>
                <TabItem Header="代码生成">
                    <ContentControl Content="{Binding CodeGeneratorViewModel.View}"/>
               
                </TabItem>
                
                <TabItem Header="系统设置">
                    
                </TabItem>
            </TabControl>

            <!--Visibility="{Binding IsBusy,Converter={StaticResource bool2Visable}}"-->
            <Grid Name="Busy" Visibility="{Binding IsBusy,Converter={StaticResource bool2Visable}}" 
                 Background="Black" Opacity=".7">
                <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Controls:ProgressIndicator Visibility="{Binding IsBusy}" Height="25" Width="300" ProgressColour="#FF9D00FF"  />
                    <TextBlock Margin="10" Foreground="White" Text="正在载入数据,请稍候......" FontSize="15" FontWeight="Normal" TextAlignment="Center" />

                </StackPanel>
              
            </Grid>
           
           
        </Grid>
       
    </Controls:MetroContentControl>
 
</Controls:MetroWindow>